const request = require("../../utils/request.js").request;
const url = require("../../utils/request.js").commonUrl;
const util = require("../../utils/util.js");
const collectUtil = require("../../utils/collect-util.js");

const app = getApp();
let actyinfo;
Page({
    data: {
        url: url,
        markers: [],
        longitude: "",
        latitude: "",
        showList: false,
        activityId: "",
        list: [],
        index: ''
    },

    getList: function (activityId) {
        let that = this;
        var params = {
            activityId: activityId,
            weixin: app.globalData.openid
        }

        request('m/activity/get.json', params).then(function (res) {
            var data = res.data.result;

            that.setData({
                list: [data]
            })
            console.log("111111", data);
        })
    },

    //跳转到活动地点
    place: function () {
        wx.redirectTo({
            url: "../place/place?act=" + JSON.stringify(actyinfo)
        })
    },

    detailGo: function (event) {
        let activityId = this.data.list[0].activityId;
        let activityAreaId = this.data.list[0].activityAreaId;
        var detailInfo = {
            activityId: activityId,
            activityAreaId: activityAreaId
        }


        wx.redirectTo({
            url: '../details/details?detailInfo=' + JSON.stringify(detailInfo)
        })
    },

    callouttap: function (e) {
        this.setData({
            showList: true,
        });

        actyinfo = {
            id: 1,
            actId: this.data.list[0].activityAreaId,
            curlati: this.data.latitude,
            curlongi: this.data.longitude
        }
    },
    //标记点事件
    makertap: function (e) {
        //点击地点显示
        this.setData({
            showList: true,
        });

        actyinfo = {
            id: 1,
            actId: this.data.list[0].activityAreaId,
            curlati: this.data.latitude,
            curlongi: this.data.longitude
        }

    },

    //点击地图隐藏
    list: function (e) {
        this.setData({
            showList: false
        })
    },

    onLoad: function (options) {
        let position = JSON.parse(options.position);
        this.setData({
            markers: [{
                id: 1,
                latitude: position.latitude,
                longitude: position.longitude,
                callout: {
                    content: position.name,
                    display: "ALWAYS",
                    padding: "5"
                }

            }],
            latitude: position.latitude,
            longitude: position.longitude,
            activityId: position.activityId
        });
        this.getList(this.data.activityId);

    },
    onShow: function () {
    }
})
